<template>
    <div class="home-container">
        <!-- 头部区域 - 左右结构 -->
        <div class="hero-section">
            <div class="hero-content">
                <h1 class="title">悦题 - <span class="highlight">智能判题</span> 服务系统</h1>
                <p class="slogan">集师生作业交互、题目发布、班级管理、积分排行、AI解答以及在线答题与判题于一体的综合性教育平台</p>
                <div class="hero-buttons">
                    <el-button type="primary" @click="gotoProblems" class="start-button">
                        <el-icon><HomeFilled /></el-icon>立即开始练习
                    </el-button>
                    <el-button class="learn-button">
                        <el-icon><Document /></el-icon>了解更多
                    </el-button>
                </div>
            </div>
            <div class="hero-image">
                <img src="https://cdn-icons-png.flaticon.com/512/2621/2621178.png" alt="Coding illustration" />
            </div>
        </div>

        <!-- 数据统计区 -->
        <div class="stats-section">
            <div class="stat-grid">
                <div class="stat-card" v-for="stat in platformStats" :key="stat.title">
                    <el-icon class="stat-icon"><component :is="stat.icon" /></el-icon>
                    <div class="stat-value">{{ stat.value }}</div>
                    <div class="stat-title">{{ stat.title }}</div>
                    <div class="stat-trend" :class="stat.trend">
                        <el-icon><ArrowUp v-if="stat.trend === 'up'" /><ArrowDown v-else /></el-icon>
                        {{ stat.rate }}%
                    </div>
                </div>
            </div>
        </div>
    </div>
    <Footer />
</template>

<script setup lang="ts">
// 尝试使用相对路径引入 Footer 组件，避免 @ 别名解析问题
import Footer from '.././components/Footer.vue'
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { 
    ArrowUp, 
    ArrowDown, 
    HomeFilled, 
    Document, 
    User, 
    Trophy, 
    Connection
} from '@element-plus/icons-vue';

const router = useRouter();

// 平台数据统计
const platformStats = ref([
    { title: '活跃用户', value: '15K+', trend: 'up', rate: 12, icon: User },
    { title: '累计题目', value: '2.3K', trend: 'up', rate: 5, icon: Document },
    { title: '提交记录', value: '458K', trend: 'up', rate: 8, icon: Connection },
    { title: '平均得分', value: '86.5', trend: 'up', rate: 2, icon: Trophy }
]);

// 导航函数
const gotoProblems = () => router.push('/problems');
</script>

<style lang="scss">
.home-container {
    width: 100%;
    background: #f8fafc;
    overflow-x: hidden;
}

// 头部区域
.hero-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 50vh;
    padding: 30px 5%;
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f4ff 100%);
    position: relative;
    overflow: hidden;

    &::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-image: 
            radial-gradient(circle at 20% 30%, rgba(64, 158, 255, 0.1) 0%, transparent 20%),
            radial-gradient(circle at 80% 70%, rgba(103, 194, 58, 0.1) 0%, transparent 20%);
        z-index: 0;
    }
}

.hero-content {
    flex: 1;
    z-index: 1;
    padding-right: 20px;
}

.hero-image {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;

    img {
        max-width: 65%;
        animation: float 6s ease-in-out infinite;
    }
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 0.8rem;
    line-height: 1.2;

    .highlight {
        background: linear-gradient(135deg, #409EFF, #67C23A);
        -webkit-background-clip: text;
        background-clip: text;
        color: transparent;
    }
}

.slogan {
    font-size: 1rem;
    color: #606266;
    margin-bottom: 1.5rem;
    max-width: 520px;
    line-height: 1.5;
}

.hero-buttons {
    display: flex;
    gap: 12px;

    .start-button {
        background: linear-gradient(135deg, #409EFF, #67C23A);
        border: none;
        padding: 8px 16px;
        font-weight: 600;
        transition: all 0.3s ease;
        
        &:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }
    }
    
    .learn-button {
        background: transparent;
        border: 1px solid #409EFF;
        color: #409EFF;
        padding: 8px 16px;
        font-weight: 600;
        transition: all 0.3s ease;
        
        &:hover {
            background: rgba(64, 158, 255, 0.05);
            transform: translateY(-2px);
        }
    }

    .el-icon {
        margin-right: 4px;
    }
}

// 统计数据区
.stats-section {
    padding: 30px 5%;
    background: white;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
}

.stat-card {
    background: white;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    
    &::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 3px;
        background: linear-gradient(90deg, #409EFF, #67C23A);
    }
    
    &:hover {
        transform: translateY(-3px);
        box-shadow: 0 8px 15px rgba(0, 0, 0, 0.08);
    }

    .stat-icon {
        color: #409EFF;
        font-size: 20px;
        margin-bottom: 10px;
    }

    .stat-value {
        font-size: 1.8rem;
        font-weight: 700;
        color: #333;
        margin-bottom: 5px;
    }

    .stat-title {
        font-size: 0.9rem;
        font-weight: 500;
        color: #606266;
        margin-bottom: 8px;
    }

    .stat-trend {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 3px 8px;
        border-radius: 10px;
        font-size: 0.75rem;
        font-weight: 600;
        
        &.up {
            color: #67C23A;
            background: rgba(103, 194, 58, 0.1);
        }
        
        &.down {
            color: #F56C6C;
            background: rgba(245, 108, 108, 0.1);
        }
    }
}

@media (max-width: 992px) {
    .hero-section {
        flex-direction: column;
        padding: 30px 5%;
        text-align: center;
    }
    
    .hero-content {
        padding-right: 0;
        margin-bottom: 20px;
    }
    
    .slogan {
        margin: 0 auto 15px;
    }
    
    .hero-buttons {
        justify-content: center;
    }
    
    .title {
        font-size: 2.2rem;
    }
}

@media (max-width: 768px) {
    .hero-section {
        min-height: auto;
        padding: 25px 5%;
    }
    
    .stats-section {
        padding: 25px 5%;
    }
    
    .stat-card .stat-value {
        font-size: 1.6rem;
    }
    
    .title {
        font-size: 1.8rem;
    }
    
    .slogan {
        font-size: 0.9rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        gap: 10px;
        width: 100%;
        max-width: 200px;
        margin: 0 auto;
        
        .el-button {
            width: 100%;
        }
    }
}
</style>